<div class="container top">
    
    <?php 
    //-----------------------------------------------------------------------------------------
      //flash messages
      if($this->session->flashdata('flash_message')){
          
        if($this->session->flashdata('flash_message') == 'updated')
        {
          echo '<div class="alert alert-success">';
            echo '<a class="close" data-dismiss="alert">×</a>';
            echo '<strong>Well done!</strong> Employee updated with success.';
          echo '</div>';       
        }else if($this->session->flashdata('flash_message') == 'deleted')
        {
          echo '<div class="alert alert-success">';
            echo '<a class="close" data-dismiss="alert">×</a>';
            echo '<strong>Well done!</strong> Employee deleted with success.';
          echo '</div>';       
        } else if($this->session->flashdata('flash_message') == 'not_deleted')
            {
          echo '<div class="alert alert-error">';
            echo '<a class="close" data-dismiss="alert">×</a>';
            echo '<strong>Oh snap!</strong> Employee did  not delete.';
          echo '</div>';          
        }
        else if($this->session->flashdata('flash_message') == 'added')
        {
          echo '<div class="alert alert-success">';
            echo '<a class="close" data-dismiss="alert">×</a>';
            echo '<strong>Well done!</strong> Employee added with success.';
          echo '</div>';       
        }
        else if($this->session->flashdata('flash_message') == 'not_added')
        {
          echo '<div class="alert alert-error">';
            echo '<a class="close" data-dismiss="alert">×</a>';
            echo '<strong>Oh snap!</strong> Employee did not add.';
          echo '</div>';       
        }
      }
  
    //effedt messages
    if($this->session->flashdata('num_row_effected')){
         if($this->session->flashdata('type')=='add'){
              echo '<div class="alert alert-success">';
              echo '<a class="close" data-dismiss="alert">×</a>';
              echo '<strong>Alert! '.$this->session->flashdata('table').' Table: </strong> Added '.$this->session->flashdata('num_row_effected').' rows.';
              echo '</div>'; 
         }else if($this->session->flashdata('type')=='update'){
             
              echo '<div class="alert alert-success">';
              echo '<a class="close" data-dismiss="alert">×</a>';
              echo '<strong>Alert! '.$this->session->flashdata('table').' Table: </strong> Updated '.$this->session->flashdata('num_row_effected').' rows.';
              echo '</div>'; 
             
         }else if($this->session->flashdata('type')=='del'){
              echo '<div class="alert alert-success">';
              echo '<a class="close" data-dismiss="alert">×</a>';
              echo '<strong>Alert! '.$this->session->flashdata('table').' Table: </strong> Deleted '.$this->session->flashdata('num_row_effected').' rows.';
              echo '</div>'; 
             
         }
        
    }
  
      
      ?>
      <ul class="breadcrumb">
        <li>
<!--          <a href="<?php echo site_url("admin"); ?>">-->
            <?php echo ucfirst($this->uri->segment(1));?>
<!--          </a> -->
          <span class="divider">/</span>
        </li>
        <li class="active">
          <?php echo ucfirst($this->uri->segment(2));?>
        </li>
      </ul>
     
      <div class="page-header users-header">
        <h2>
          <?php echo ucfirst($this->uri->segment(2));?> 
          <a  href="<?php echo base_url("index.php/employee/add") ?>" class="btn btn-success">Add a new</a>
        </h2>
      </div> 

      
      <div class="row">
        <div class="span12 columns">
             <ul class="nav nav-tabs ">
                    <li class="active">
                      <a href="<?php echo base_url("index.php/employee") ?>" class="btn btn-default">Employee </a>
                    </li>
                    <li>
                            <a href="<?php echo base_url("index.php/project") ?>" class="btn btn-default">Project </a>
                    </li>
                    <li>
                         <a href="<?php echo base_url("index.php/department") ?>" class="btn btn-default">Department </a>
                    </li>
                     <li> 
                         <a href="<?php echo base_url("index.php/workon") ?>" class="btn btn-default">Workon </a>
                    </li>
             </ul>
          <!-- <div class="well"> -->
          
                    <dl>
                        <dt> Update a field: </dt>
                        <dd><b><i><small>If Type of values is TEXT or DATE, please add ''. ex: 'Nguyen Van A' or '10-NOV-12'</small></i></b> </dd>
                        <dd>
                            <?php
                             echo validation_errors();
                        $attributes = array('class' => 'form-inline', 'id' => '');
                        echo form_open('index.php/employee/update_a_field', $attributes);
                        
                        ?>
                         
                         
                                <label ><code> UPDATE Employee SET</code></label>
                                <select name="af_emp_field" class="input-medium">
                                        <option value="NAME">NAME</option>
                                        <option value="BIRTHDAY">BIRTHDAY</option>
                                        <option value="EMAIL">EMAIL</option>
                                        <option value="EMP_LEVEL">EMP_LEVEL</option>
                                        <option value="TAX_NUM">TAX_NUM</option>
                                        <option value="SALARY">SALARY</option>
                                        <option value="DEP_ID">DEP_ID</option>
                                </select>
    
                                <label ><code> =</code></label>
                              <input type="text" id="v_value" name="af_value" placeholder="Value" class="input-mini">
                               <label ><code> WHERE EMP_ID = </code></label>
<!--                                <input type="text" id="v_value" name="af_emp_id" placeholder="EMP_ID" class="input-mini">-->
                                <select name="af_emp_id" class="input-small">
                                 <?php
                                    foreach ($employee as $row) {
                                        echo '<option value="'.$row[0].'">'.$row[0].'</option>';
                                   }
                                ?>
                                 </select>
                                
                                <label> &DoubleRightArrow; </label>
                                <button class="btn btn-primary" type="submit">Execute</button>
                             <?php echo form_close(); ?>
                     </dd>
                     </dl>
              
          
           
          <table class="tablesorter  ">
            

            <thead>
              <tr>
                  <th >#</th>
                 <th>EMP_ID</th>
                 <th >Name</th>
                 <th >Birthday</th>
                 <th>Email</th>
                 <th >Level</th>
                 <th >Tax</th>
                 <th>Sal</th>
                 <th >Dept</th>
                 <th ></th>
                 <th ></th>
             
              </tr>
            </thead>
                
              <?php
              $x=1;
              foreach($employee as $row)
              {
                  if(($x%2) ==0){
                  echo "<tr class='info' >";
                  }
                  else{
                      echo "<tr class='warning'>";
                  }
                  
                  echo "<td>".$x ."</td >";
                  
                echo '<td>'.$row[0].'</td>';
                echo '<td>'.$row[1].'</td>';
                echo '<td>'.$row[2].'</td>';
                echo '<td>'.$row[3].'</td>';
                echo '<td>'.$row[4].'</td>';
                echo '<td>'.$row[5].'</td>';
                echo '<td>'.$row[7].'</td>';
                echo '<td>'.$row[6].'</td>';
                  
                  echo '<td>
                  <a href="'.base_url("index.php/employee/update").'/'.$row[0].'" class="btn btn-info">Edit</a>  
                    </td>';
                  echo '<td>
                  <a href="'.base_url("index.php/employee/delete").'/'.$row[0].'" class="btn btn-danger ">Del</a>  
                    </td>';
                  
                  $x = $x+1;
              }
              ?>                  
          
            
          </table>

          

      </div>
    </div>